package com.itheima.service.impl;

import com.itheima.dao.UserDao;
import com.itheima.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;

/**
 * @author wuli
 * @create 2021-11-15 22:20
 */
//<bean id="userService" class="com.itheima.service.impl.UserServiceImpl">
@Service("userService")
public class UserServiceImpl implements UserService {

    //<property name="userDao" ref="userDao"></property>
    //@Autowired
    //@Qualifier("userDao")
    @Resource(name ="userDao")
    private UserDao userDao;

    @Value("${jdbc.url}")
    private String url;

    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    public void save() {
        System.out.println(url);
        userDao.save();
    }

    @PostConstruct
    public void init() {
        System.out.println("init...");
    }

    @PreDestroy
    public void destroy() {
        System.out.println("destroy...");
    }
}
